package com.example.libraryapp.notice;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.database.Cursor;

import com.example.libraryapp.db.MySqliteHelper;
import com.example.libraryapp.util.Constance;

/**
 * 公告服务，主要提供对公告信息的管理
 */
public class NoticeService {
	/**
	 * 得到所有的信息
	 * 
	 * @return
	 */
	public static List<NoticeInfo> getAllNotice(Context context) {

		List<NoticeInfo> NoticeList = null;
		Cursor cursor = MySqliteHelper.getInstance(context).query(
				Constance.NOTICE_TABLE_NMAE, " 1=1 ");
		if (cursor != null) {
			NoticeList = new ArrayList<NoticeInfo>();
			while (cursor.moveToNext()) {
				NoticeInfo noticeInfo = new NoticeInfo();
				noticeInfo.setId(cursor.getInt(cursor.getColumnIndex("id"))
						+ "");
				noticeInfo.setTitle(cursor.getString(cursor
						.getColumnIndex("title")));
				noticeInfo.setPublishingTime(cursor.getString(cursor
						.getColumnIndex("pubtime")));
				NoticeList.add(noticeInfo);
			}
		}
		return NoticeList;
	}

	/**
	 * 根据条件得到借阅
	 * 
	 * @return
	 */
	public static List<NoticeInfo> getNoticeDatail(Context context,
			String param) {
		return null;
	}
}
